<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>

<jsp:directive.include file="/controleDeAcesso/autenticado.jsp" />

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Classificado Pessoal</title>
</head>
<body>
<f:view>
<h2>Classificado Pessoal de <h:outputText value="#{principal.usuario.nome}"></h:outputText>
</h2>
		<h:form>
			<h:commandLink action="cadastrarAnuncio">
				<h:outputText value="(+) Castrar um novo Anúncio no seu Classificados"></h:outputText>
			</h:commandLink>
		</h:form><br/>
		
		<h:outputText value="#{principal.msg}" style="color: #FF0000"></h:outputText>
		
		<h:dataTable border="1" value="#{principal.usuario.listaAnuncios}" var="anuncio">
			<h:column id="column1">
				<f:facet name="header">
					<h:outputText value="Identificador"></h:outputText>
				</f:facet>
				<h:outputText value="#{anuncio.id}"></h:outputText>
			</h:column>
			<h:column id="column2">
				<f:facet name="header">
					<h:outputText value="Resumo"></h:outputText>
				</f:facet>
				<h:outputText value="#{anuncio.resumo}"></h:outputText>
			</h:column>
			<h:column id="column3">
				<f:facet name="header">
					<h:outputText value="Detalhamento"></h:outputText>
				</f:facet>
				<h:outputText value="#{anuncio.detalhamento}"></h:outputText>
			</h:column>
			<h:column id="column4">
				<f:facet name="header">
					<h:outputText value="Valor"></h:outputText>
				</f:facet>
				<h:outputText value="#{anuncio.valor}"></h:outputText>
			</h:column>
			<h:column id="column5" >
				<f:facet name="header">
					<h:outputText value="Ações"></h:outputText>
				</f:facet>
				<h:form>
					<h:commandLink action="alterarAnuncio">
						<h:outputText value="Editar"></h:outputText>
						<f:setPropertyActionListener value="#{anuncio}" target="#{principal.anuncio}"/>
					</h:commandLink>
					<h:outputText value=" | "></h:outputText>
					<h:commandLink action="#{principal.removeAnuncio}">
						<h:outputText value="Remover"></h:outputText>
						<f:setPropertyActionListener value="#{anuncio}" target="#{principal.anuncio}"/>
					</h:commandLink>
				</h:form>
			</h:column>
		</h:dataTable>
		<br/>	
		<h:form>
			<h:commandButton value="Logout" action="#{principal.logout}" ></h:commandButton>
		</h:form>
	</f:view>
</body>
</html>